﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Globalization;

/// <summary>
///YalieRecord 的摘要说明
/// </summary>
public class YalieRecord : SingleRecord
{
    public decimal? SGJDDS1 { get; set; }
    public decimal? SGJDDS2 { get; set; }
    public decimal? CWSYHD { get; set; }
    public decimal? CWYXHD { get; set; }
    public int? CH { get; set; }
    public string YLRQ { get; set; }
    public string YLCS { get; set; }
    public decimal? PLYL { get; set; }
    public decimal? HSB { get; set; }
    public decimal? JSL { get; set; }
    //属性用大写，参数用小写，容易区分。

    public YalieRecord(string jh, string jb, string cslb, string kgrq, string wgrq, string csmc, string sgfs, string cscd, string bz, decimal sgjdds1, decimal sgjdds2, decimal cwsyhd, decimal cwyxhd, int ch, string ylrq, string ylcs, decimal plyl, decimal hsb, decimal jsl)
        : base(jh, jb, cslb, kgrq, wgrq, csmc, sgfs, cscd, bz)
    {
        SGJDDS1 = sgjdds1;
        SGJDDS2 = sgjdds2;
        CWSYHD = cwsyhd;
        CWYXHD = cwyxhd;
        CH = ch;
        YLRQ = ylrq;
        YLCS = ylcs;
        PLYL = plyl;
        HSB = hsb;
        JSL = jsl;

        SelectStr = "select count(*) from bc_cscgjl where jh='" + JH + "' and jb='" + JB + "' and kgrq=to_date('" + KGRQ + "','yyyy-mm-dd') and cslb='" + CSLB + "' and ch ='" + CH + "' and sgjdds1='" + SGJDDS1 + "' and ylrq='" + YLRQ + "' and ylcs ='" + YLCS + "'";
        InsertStr = "insert into bc_cscgjl(jh,jb,cslb,kgrq,wgrq,csmc,sgfs,cscd,bz,sgjdds1,sgjdds2,cwsyhd,cwyxhd,ch,ylrq,ylcs,plyl,hsb,jsl) values('" + JH + "','" + JB + "','1200',to_date('" + KGRQ + "','yyyy-mm-dd'),to_date('" + WGRQ + "','yyyy-mm-dd'),'" + CSMC + "','" + SGFS + "','" + CSCD + "','" + BZ + "'," + SGJDDS1 + "," + SGJDDS2 + "," + CWSYHD + "," + CWYXHD + "," + CH + ",to_date('" + YLRQ + "','yyyy-mm-dd'),'" + YLCS + "'," + PLYL + "," + HSB + "," + JSL + ")";
        //UpdateStr = "update bc_cscgjl set jh='" + JH + "',jb='" + JB + "',cslb='"+ CSLB + "',kgrq='" + KGRQ + "',wgrq='" + WGRQ + "',csmc='" + CSMC + "',sgfs='" + SGFS + "',cscd='" + CSCD + "',bz='" + BZ + "',sgjdds1='" + SGJDDS1 + "',sgjdds2='" + SGJDDS2 + "',cwsyhd='"+CWSYHD+"',cwyxhd='"+cwyxhd+"',ch='" + CH +"',ylrq='"+YLRQ+"',ylcs='" + YLCS+"',plyl='"+ PLYL +"',hsb='" + HSB + "',jsl='"+ JSL + "'";
        
    }
    public YalieRecord(DataRow dr): base(dr)
    {
        //decimal d_temp;
        //int i_temp;
        //decimal.TryParse(dr["施工层段顶深"].ToString(),out d_temp);
        //SGJDDS1 = d_temp;
        //decimal.TryParse(dr["施工层段底深"].ToString(),out d_temp);
        //SGJDDS2 = d_temp;
        //decimal.TryParse(dr["措施层位砂岩厚度"].ToString(),out d_temp);
        //CWSYHD = d_temp;
        //decimal.TryParse(dr["措施层位有效厚度"].ToString(),out d_temp);
        //CWYXHD = d_temp;
        //int.TryParse(dr["小层号"].ToString(),out i_temp);
        //CH = i_temp;
        //YLRQ = dr["压裂日期"].ToString();
        //YLCS = dr["压裂层数"].ToString();
        //decimal.TryParse(dr["破裂压力"].ToString(),out d_temp);
        //PLYL = d_temp;
        //decimal.TryParse(dr["换砂比"].ToString(),out d_temp);
        //HSB = d_temp;
        //decimal.TryParse(dr["加砂量"].ToString(),out d_temp);
        //JSL = d_temp;

        if (String.IsNullOrEmpty(dr["施工层段顶深"].ToString()))
        {
            SGJDDS1 = null;
        }
        else
        {
            SGJDDS1 = decimal.Parse(dr["施工层段顶深"].ToString());
        }

        if (String.IsNullOrEmpty(dr["施工层段底深"].ToString()))
        {
            SGJDDS2 = null;
        }
        else
        {
            SGJDDS2 = decimal.Parse(dr["施工层段底深"].ToString());
        }
        if (String.IsNullOrEmpty(dr["措施层位砂岩厚度"].ToString()))
        {
            CWSYHD = null;
        }
        else
        {
            CWSYHD = decimal.Parse(dr["措施层位砂岩厚度"].ToString());
        }
        if (String.IsNullOrEmpty(dr["措施层位有效厚度"].ToString()))
        {
            CWYXHD = null;
        }
        else
        {
            CWYXHD = decimal.Parse(dr["措施层位有效厚度"].ToString());
        }
        if (String.IsNullOrEmpty(dr["小层号"].ToString()))
        {
            CH = null;
        }
        else
        {
            CH = int.Parse(dr["小层号"].ToString());
        }
        //string 类型不用处理为空的情况
        YLRQ = dr["压裂日期"].ToString();
        YLCS = dr["压裂层数"].ToString();

        if (String.IsNullOrEmpty(dr["破裂压力"].ToString()))
        {
            PLYL = null;
        }
        else
        {
            PLYL = decimal.Parse(dr["破裂压力"].ToString());
        }
        if (String.IsNullOrEmpty(dr["换砂比"].ToString()))
        {
            HSB = null;
        }
        else
        {
            HSB = decimal.Parse(dr["换砂比"].ToString());
        }
        if (String.IsNullOrEmpty(dr["加砂量"].ToString()))
        {
            JSL = null;
        }
        else
        {
            JSL = decimal.Parse(dr["加砂量"].ToString());
        }
        //用selectStr判断是否记录唯一 is null 正确 而用 ='' 错误
        SelectStr = "select count(*) from bc_cscgjl where jh='" + JH + "' and jb='" + JB + "' and kgrq='" + KGRQ + "' and cslb='" + CSLB + "' and ch ='" + CH + "' and sgjdds1='" + SGJDDS1 + "' and ylrq='" + YLRQ + "' and ylcs ='" + YLCS + "'";
        InsertStr = "insert into bc_cscgjl(jh,jb,cslb,kgrq,wgrq,csmc,sgfs,cscd,bz,sgjdds1,sgjdds2,cwsyhd,cwyxhd,ch,ylrq,ylcs,plyl,hsb,jsl) values('" + JH + "','" + JB + "','"+ CSLB +"',to_date('" + KGRQ + "','yyyy-mm-dd'),to_date('" + WGRQ + "','yyyy-mm-dd'),'" + CSMC + "','" + SGFS + "','" + CSCD + "','" + BZ + "','" + SGJDDS1 + "','" + SGJDDS2 + "','" + CWSYHD + "','" + CWYXHD + "','" + CH + "',to_date('" + YLRQ + "','yyyy-mm-dd'),'" + YLCS + "','" + PLYL + "','" + HSB + "','" + JSL + "')";
        //UpdateStr = "update bc_cscgjl set jh='" + JH + "',jb='" + JB + "',cslb='" + CSLB + "',kgrq='" + KGRQ + "',wgrq='" + WGRQ + "',csmc='" + CSMC + "',sgfs='" + SGFS + "',cscd='" + CSCD + "',bz='" + BZ + "',sgjdds1='" + SGJDDS1 + "',sgjdds2='" + SGJDDS2 + "',cwsyhd='" + CWSYHD + "',cwyxhd='" + CWYXHD + "',ch='" + CH + "',ylrq='" + YLRQ + "',ylcs='" + YLCS + "',plyl='" + PLYL + "',hsb='" + HSB + "',jsl='" + JSL + "'";
        
    }
    
}